@extends('admin.main')

@section('content')
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <h5>订单列表</h5>
        </div>
        <div class="ibox-content">
            <div class="table-responsive">
                <form role="form" id="formData" class="form-inline">
                    <div class="form-group">
                        <input name="number" type="text" placeholder="会员编号"  class="form-control" value="{{$param['number']}}">
                    </div>
                    <div class="form-group">
                        <input type="text" name="order_no" placeholder="订单号" class="form-control" value="{{$param['order_no']}}">
                    </div>
                    <div class="form-group">
                         <select class="form-control " name="type">
                            <option value="" @if($param['type'] =='') selected @endif>---订单类型----</option>
                            <option value="box"  @if($param['type'] =='box') selected @endif>会员服务</option>
                            <option value="act"  @if($param['type'] =='act') selected @endif>活动报名</option>
                            <option value="energy"  @if($param['type'] =='energy') selected @endif>能量加油</option>
                        </select>
                    </div>
                   <div class="form-group">
                        <div class=" input-group">
                            <input type="text" class="input-sm form-control" name="pay_time" id="datetime" value="{{$param['pay_time']}}"  placeholder="支付时间">
                        </div>
                    </div>
                    <button class="btn btn-primary btn-sm" type="submit" id="buttonData">搜索</button>
                    <a class="btn btn-primary pull-right" href="javascript:;" id="btn-export">导出报表</a>
                </form>
                <div class="hr-line-dashed"></div>
                <table id="tblDataList" class="table table-striped table-bordered">
                    <thead>
                        <tr>
                            <!-- <th width="50" class="text-center"><input type="checkbox" id="checkAll" title="全选" /></th> -->
                            <th width="50" class="text-center">#</th>
                            <th>会员编号</th>
                            <th>订单号</th>
                            <th>订单名称</th>
                            <th>创建时间</th>
                            <th>用户</th>
                            <th>订单状态</th>
                            <th>订单类型</th>
                            <th>支付金额</th>
                            <th>支付时间</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($rows as $k=>$row)
                        <tr data-id="{{$row->id}}">
                            <!-- <td class="text-center"><input type="checkbox" name="ids" value="{{$row->id}}" /></td> -->
                            <td class="text-center">
                                {{($rows->currentPage()-1) * $rows->perPage() + ($k+1)}}
                            </td>
                            <td>{{$row->user->number}}</td>
                            <td>{{$row->order_no}}</td>
                            <td>{{$row->name}}</td>
                            <td>{{$row->created_at}}</td>
                            <td>
                                {{$row->user->nickname}}
                            </td>
                            <td>{{$row->pay_status_handle}}</td>
                            <td>{{$row->pay_type_handle}}</td>
                            <td>{{$row->total_amount_handle}}</td>
                            <td>
                                {{$row->pay_time}}
                            </td>
                                <!-- <a href="{{url('admin/link/edit/'.$row->id)}}" class="m-r-xs">
                                    <i class="fa fa-pencil-square fa-lg"></i> 编辑
                                </a> -->
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
                <div class="text-center"><?php echo $rows->appends($param)->links(); ?></div>
            </div>
        </div>
    </div>
</div>


@endsection
@section('pageheader')
@endsection
    <script src="/assets/layDate/laydate.js"></script>
@section('pagescript')
<script>
    $("#side-menu li[rel='order']").addClass("active");
    $(function(){
        laydate.render({
            elem: '#datetime'
        });

        $('#btn-export').click(function(){
            var formDate = $('#formData').serialize();
            var url = '/admin/order/export?='+formDate;
            windowOpen(url,'_blank');
        })
    })
    //打开新链接方法实现 避免浏览器拦截
    function windowOpen(url,target){
        var a = document.createElement("a");
        a.setAttribute("href", url);
        if(target == null){
            target = '';
        }
        a.setAttribute("target", target);
        document.body.appendChild(a);
        if(a.click){
            a.click();
        }else{
            try{
                var evt = document.createEvent('Event');
                a.initEvent('click', true, true);
                a.dispatchEvent(evt);
            }catch(e){
                window.open(url);
            }
        }
        document.body.removeChild(a);
    }
</script>
@endsection
